<?php

class Sgit_Controller_Plugin_Language  extends Zend_Controller_Plugin_Abstract
{
    
    public function __construct($zonasRutas)
    {
        $this->_zonasRutas=$zonasRutas;
    }
    public function routeShutdown(Zend_Controller_Request_Abstract $request)
    {
        $dc = $request->getParam('dc', null);
        
        foreach($this->_zonasRutas as $k => $v){
            if(strtolower($dc)==$v) {
                if($k)$request->setParam('idZona', $k);
                break;
            }
        }
        
        
        // Set language to global param so that our language route can
        // fetch it nicely.
        $front = Zend_Controller_Front::getInstance();
        $router = $front->getRouter();
        
       
        $router->setGlobalParam('dc', $dc);
    }
}